package com.devilvan.betrice.sinofinance.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.devilvan.betrice.sinofinance.dto.SinaAsharesQuotesDto;
import com.devilvan.betrice.sinofinance.po.SinaAsharesQuotesPo;
import com.devilvan.betrice.sinofinance.service.SinaAsharesQuotesService;
import com.devilvan.betrice.sinofinance.mapper.SinaAsharesQuotesMapper;
import com.devilvan.betrice.sinofinance.repository.SinaAsharesQuotesRepository;
import com.devilvan.betrice.util.UCopy;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
* @author Evad.Wu
* @Description 新浪财经-A股实时行情信息表 业务逻辑类
* @date 2023-03-22
*/
@Service
public class SinaAsharesQuotesServiceImpl extends ServiceImpl<SinaAsharesQuotesMapper, SinaAsharesQuotesPo> implements SinaAsharesQuotesService {
    @Resource(name = "sinaAsharesQuotesRepository")
    private SinaAsharesQuotesRepository sinaAsharesQuotesRepository;

    @Override
    public SinaAsharesQuotesPo saveUpdate(SinaAsharesQuotesDto sinaAsharesQuotesDto) {
        SinaAsharesQuotesPo sinaAsharesQuotesPo = new SinaAsharesQuotesPo();
        UCopy.fullCopy(sinaAsharesQuotesDto, sinaAsharesQuotesPo);
        return sinaAsharesQuotesRepository.saveAndFlush(sinaAsharesQuotesPo);
    }

    @Override
    public List<SinaAsharesQuotesPo> saveUpdateBatch(List<SinaAsharesQuotesDto> list) {
        List<SinaAsharesQuotesPo> sinaAsharesQuotesPoList = UCopy.fullCopyCollections(list, SinaAsharesQuotesPo.class);
        return sinaAsharesQuotesRepository.saveAllAndFlush(sinaAsharesQuotesPoList);
    }
}
